home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Taiji Applet Pack v2.7 / StatusBarScroller2 / StatusBarScroller2.class (.txt) < prev    next >
Encoding:
Java Class File  |  2001-11-06  |  4.4 KB  |  184 lines

  1. import java.applet.Applet;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.net.URL;
  5.  
  6. public class StatusBarScroller2 extends Applet implements Runnable {
  7.    private String text;
  8.    // $FF: renamed from: wi int
  9.    private int field_0;
  10.    // $FF: renamed from: he int
  11.    private int field_1;
  12.    private Thread thread;
  13.    private int pause = 50;
  14.  
  15.    public String getAppletInfo() {
  16.       return "Name: StatusBarScroller2\r\nAuthor: Taiji Software\r\n";
  17.    }
  18.  
  19.    public void register() {
  20.       try {
  21.          URL u = new URL("http://www.taijisoftware.com");
  22.          ((Applet)this).getAppletContext().showDocument(u, "_blank");
  23.       } catch (Exception e) {
  24.          System.out.println(e);
  25.          this.stop();
  26.       }
  27.    }
  28.  
  29.    public void init() {
  30.       String codeBase = null;
  31.  
  32.       try {
  33.          codeBase = (new URL(((Applet)this).getCodeBase().toString())).getHost();
  34.          System.out.println("Copyright 1999, 2001 Taiji Software(tm)\nYour domain name is : " + codeBase);
  35.          codeBase = codeBase.toUpperCase();
  36.       } catch (Exception var9) {
  37.       }
  38.  
  39.       if (!((Applet)this).getCodeBase().toString().toUpperCase().startsWith("FILE") || ((Applet)this).getParameter("debug") != null) {
  40.          String regCode = ((Applet)this).getParameter("registration_code");
  41.          if (regCode == null) {
  42.             regCode = ((Applet)this).getParameter("reg_domain");
  43.             if (regCode == null) {
  44.                this.register();
  45.             } else {
  46.                if (regCode.length() == codeBase.length() + 4 && !codeBase.startsWith("WWW.")) {
  47.                   codeBase = "WWW." + codeBase;
  48.                } else if (regCode.length() == codeBase.length() - 4 && codeBase.startsWith("WWW.")) {
  49.                   codeBase = codeBase.substring(4);
  50.                }
  51.  
  52.                char[] chars = new char[codeBase.length()];
  53.                codeBase.getChars(0, codeBase.length(), chars, 0);
  54.                String key = new String("haricot");
  55.                char[] chars2 = new char[key.length()];
  56.                key.getChars(0, key.length(), chars2, 0);
  57.  
  58.                for(int i = 0; i < codeBase.length(); ++i) {
  59.                   int j;
  60.                   if (i >= key.length()) {
  61.                      j = i - key.length() * (i / key.length());
  62.                   } else {
  63.                      j = i;
  64.                   }
  65.  
  66.                   chars[i] += chars2[j];
  67.                   chars[i] = (char)(chars[i] - chars[i] / 26 * 26 + 97);
  68.                }
  69.  
  70.                String res = new String(chars);
  71.                if (!res.equalsIgnoreCase(regCode)) {
  72.                   this.register();
  73.                }
  74.             }
  75.          } else if (!regCode.equals("settevercsedegnamiaj") && !regCode.equals("8078")) {
  76.             this.register();
  77.          }
  78.       }
  79.  
  80.       this.field_0 = ((Component)this).getSize().width;
  81.       this.field_1 = ((Component)this).getSize().height;
  82.       String s = ((Applet)this).getParameter("pause");
  83.       if (s != null) {
  84.          this.pause = Integer.parseInt(s);
  85.       }
  86.  
  87.       this.text = ((Applet)this).getParameter("text");
  88.       ((Component)this).setBackground(this.getColor("background_color"));
  89.       this.thread = new Thread(this);
  90.       this.thread.start();
  91.    }
  92.  
  93.    public Color getColor(String param) {
  94.       String s = ((Applet)this).getParameter(param);
  95.       if (s != null) {
  96.          if (s.substring(0, 1).equals("#")) {
  97.             s = s.substring(1);
  98.             int i = Integer.parseInt(s, 16);
  99.             return new Color(i);
  100.          } else {
  101.             return null;
  102.          }
  103.       } else {
  104.          return null;
  105.       }
  106.    }
  107.  
  108.    public void run() {
  109.       int c = 0;
  110.  
  111.       int m;
  112.       for(m = 0; (c = this.text.indexOf("#", c)) != -1; ++m) {
  113.          ++c;
  114.       }
  115.  
  116.       String[] lines = new String[m + 1];
  117.       if (m != 0) {
  118.          int[] index = new int[m];
  119.  
  120.          for(m = 0; (c = this.text.indexOf("#", c)) != -1; ++m) {
  121.             index[m] = c;
  122.             if (m == 0) {
  123.                lines[m] = this.text.substring(0, index[0]);
  124.             } else {
  125.                lines[m] = this.text.substring(index[m - 1] + 1, index[m]);
  126.             }
  127.  
  128.             ++c;
  129.          }
  130.  
  131.          lines[m] = this.text.substring(index[m - 1] + 1);
  132.       } else {
  133.          lines[m] = this.text;
  134.       }
  135.  
  136.       int l = 1;
  137.       int L = 0;
  138.       int P = 0;
  139.  
  140.       while(true) {
  141.          try {
  142.             ((Applet)this).showStatus(lines[L].substring(0, l));
  143.             Thread.sleep(20L);
  144.          } catch (Exception var8) {
  145.          }
  146.  
  147.          P += 20;
  148.          if (P > this.pause) {
  149.             ++l;
  150.             if (l >= lines[L].length() + 1) {
  151.                l = 0;
  152.  
  153.                try {
  154.                   Thread.sleep(1000L);
  155.                } catch (Exception var7) {
  156.                }
  157.  
  158.                ++L;
  159.                if (L > m) {
  160.                   L = 0;
  161.                }
  162.             }
  163.  
  164.             P = 0;
  165.          }
  166.       }
  167.    }
  168.  
  169.    public void start() {
  170.       if (this.thread == null) {
  171.          this.thread = new Thread(this);
  172.          this.thread.start();
  173.       }
  174.  
  175.    }
  176.  
  177.    public void stop() {
  178.       if (this.thread != null) {
  179.          this.thread = null;
  180.       }
  181.  
  182.    }
  183. }
  184.